/********************************************************************************
 * AdditionalOptionsFeesServiceDelegator.java
 *
 * Created by Jigar Mistry
 * Last modified Date: Sep 10, 2008 10:17:38 AM by Jigar Mistry
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 ********************************************************************************/

package com.printeverywhere.delegator;

import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.printeverywhere.dto.AdditionalOptionsFees;
import com.printeverywhere.util.HibernateUtil;

/**
 * The Class AdditionalOptionsFeesServiceDelegator.
 */
public class AdditionalOptionsFeesServiceDelegator {
	
	/** The log. */
	private static Logger log = Logger.getLogger(AdditionalOptionsFeesServiceDelegator.class);

	/**
	 * Gets the auction listing fees.
	 * 
	 * @return the auction listing fees
	 * 
	 * @throws HibernateException the hibernate exception
	 */
	@SuppressWarnings("unchecked")
	public static List<AdditionalOptionsFees> getAdditionalOptionsFees() throws HibernateException {
		if(log.isInfoEnabled()){
			log.info("Getting list for AdditionalOptionsFees without search criteria".intern());
		}
		Session session = HibernateUtil.getSession();
		try {
			Transaction transaction = session.beginTransaction();
			List<AdditionalOptionsFees> AdditionalOptionsFeesList = session.createCriteria(AdditionalOptionsFees.class).list();
			transaction.commit();
			return AdditionalOptionsFeesList;
		} catch (HibernateException e) {
			log.error("Got exception when getting list for AdditionalOptionsFees without search criteria".intern());
			throw e;
		} finally {
			if(log.isInfoEnabled()){
				log.info("Closing session".intern());
			}
			session.flush();
			session.close();
		}
	}

	/**
	 * Update mailing system.
	 * 
	 * @param AdditionalOptionsFees the mailing system
	 * 
	 * @throws HibernateException the hibernate exception
	 */
	public static void updateAdditionalOptionsFees(AdditionalOptionsFees AdditionalOptionsFees) throws HibernateException {
		if(log.isInfoEnabled()){
			log.info("Called updateAdditionalOptionsFees method".intern());
		}
		Session session = HibernateUtil.getSession();
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
			session.update(AdditionalOptionsFees);
			tx.commit();
		} catch (RuntimeException e) {
			log.error("Got exception when update AdditionalOptionsFees without search criteria".intern());
			if (tx != null)
				tx.rollback();
			throw e;
		} finally {
			if(log.isInfoEnabled()){
				log.info("Closing session".intern());
			}
			session.flush();
			session.close();
		}
	}
}